package model;

import persistency.controller.RegistrationController;


public class OfferedCourseFullState implements OfferedCourseState {

	private OfferedCourse offeredCourse;
	
	public OfferedCourseFullState(OfferedCourse offeredCourse){
		this.offeredCourse = offeredCourse;
	}
	
	
	@Override
	public boolean registerStudent(Registration registration) throws Exception {
		throw new Exception("registration full");
		
	}

	@Override
	public void unregisterStudent(Registration registration) {
		RegistrationController.instance().deleteRegistration(registration.getId());
		offeredCourse.setState(offeredCourse.getOfferedCourseOpenState());
		
	}

	@Override
	public void closeRegistration() {
		offeredCourse.setState(offeredCourse.getOfferedCourseClosedState());
		
	}

	@Override
	public void cancelOfferedCourse() {
		offeredCourse.setState(offeredCourse.getOfferedCourseCanceledState());
		
	}
	
	@Override
	public String toString(){
		return model.enums.OfferedCourseState.FULL.toString();
	}

}
